
 //Purpose: This file creates the Appendix Figures for Crimes Against Morality
 //First version: August 22, 2020; Gabriela Rubio
 //This version: September 21, 2020; Jennifer Seager
 *********************************************************************************
 ** CRIMES AGAINST MORALITY: UNINTENDED CONSEQUENCES OF CRIMINALIZING SEX WORK ***
 *********************************************************************************
 
 clear
 clear matrix
 estimates clear
 eststo clear
 cap log close
 set more off
 set mem 400m
 
 //Directory set in file #0
 
 ********************************
 ****** APPENDIX FIGURES ********
 ********************************
 
  ssc install grstyle
 ssc install cibar
 ******************************** 
 *** Figure I.I: Sample Sizes ***
 ********************************


 clear all
 import excel "$df/Histogram.xlsx", sheet("Sheet2") firstrow

 replace Survey="February/March-2014" if Survey=="Mar 2014"
 replace Survey="Sep-2014" if Survey=="Sep 2014"
 replace Survey="September-2014" if Survey=="Sep-2014"
 replace Survey="May/June-2015" if Survey=="May 2015"
 replace Survey="October-2019" if Survey=="October 2019"
 replace Survey="October-2019" if Survey=="Oct 2019"
 graph bar (first) Population, over(Type, sort(Order)) blabel(total, size(vsmall)) ///
 over(Survey, gap(*4) sort(Order)) asy bar(1, fcolor(gs9) lcolor(gs8)) ///
 bar(2, fcolor(gs11) lcolor(gs10)) bar(3, fcolor(gs13) lcolor(gs12)) ///
 bar(4, fcolor(gs14) lcolor(gs13)) legend(all rows(2) size(vsmall)) ///
 bar(5, fcolor(gs5) lcolor(gs4)) legend(all rows(2) size(vsmall)) ///
 ylabel(0 "0" 50 "50" 100 "100" 150 "150" 200 "200" 250 "250" 300 "300" 350 "350" 400 "400" 450 "450" 500 "500" 550 "550", angle(0) labsize(small)) ///
 ymlabel(600 " ", nolabels tlength(zero)) ///
 ytitle("Number of Sex Workers") ///
 yline(550, lcolor(gs14)) ///
 yscale(titlegap(*12)) legend(order(5 1  2 3 4) rows(2) size(vsmall)) ///
 text(599 20 "Pre-criminalization") text(599 75 "Post-criminalization") ///
 text(570 7 "Pre-announcement", size(vsmall)) text(570 35 "Post-announcement", size(vsmall)) 

 *Note: add manually the vertical line.
 
 graph export "$dout/Fig_I-I_histogram", as (pdf) replace


 *******************************************************************
 *** Figure I.II: Mean of key outcomes by criminalization status ***
 *******************************************************************
 
 #delimit;
 clear;
 clear matrix;
 estimates clear;
 eststo clear;
 cap log close;
 set more off;
 set mem 400m;


 *1. Input data;
use "$da/Crimes-Against-Morality_Main_data-constructed.dta", clear;

 *2. Setting Macros;
 *2.1. Setting sample restrictions for DD;
 *2.1.1. For the FSW Data;
 local sw1 = "if sw==1&dataset==1&full==1";
	*still in sex work;
 local sw2 = "if panel_v3==1&dataset==1";
	*in the panel and still in sex work;
 local sw3 = "if panelsti_sept==1&dataset==1";
	*in the September STI panel.;
 local sw4 = "if wspanel==1&dataset==1";

 *2.1.2. For the FSW transaction data;
 local tsw1 = "if dataset==2&full==1";
 local tsw2 = "if panel_f==1 & dataset==2&full==1";

 *2.1.3. For the Client Data;
 local c1 = "if dataset==3";

 *2.1.4. For the Client transaction data;
 local tc1 = "if dataset==4";

 *2.2. Setting controls;
 local char = 
	"divwid unmarried edyrs age children sw_locyrs disc_factor risktol_nodl nodlr ";
 local tchar1 = "regular outsider clean handsome old rich";
 local tchar2 = "regular";
 local cchar = "divwid unmarried edyrs age disc_factor risktol";
 local tcchar = "regular clean attractive";

*HEALTH EXAMS;
 *T-test for equality of means: Baseline vs Endline;

 *Non-criminalized:;
 reg hlthacc el if dataset==1 & sw==1 & full==1  & closing==0, r;
 *Criminalized:;
 reg hlthacc el if dataset==1 & sw==1 & full==1  & closing==1, r;


 *Figure:;
 *DD p-value;
 reg hlthacc dd_cl el closing if sw==1&dataset==1&full==1 & condeasy!=., cluster(wsid);
 boottest  dd_cl, reps (10000) bootcluster(wsid);

 *Without pattern:;
 cibar hlthacc if dataset==1 & sw==1 &full==1, over1(el) over2(closing) ciopts(lcolor(black))bargap(3) 
 graphopts(legend(order(1 "Baseline" 2 "Endline")) ylabel(0 "0" .1 ".1" .2 ".2" .3 ".3" .4 ".4" .5 ".5" .6 ".6" .7 ".7" .8 ".8" .9 ".9" 1 "1", angle(0)) 
 ymlabel(1.1 " " 1.2 " " 1.3 " ", nolabels tlength(zero)) ytitle("") 
 xlabel(1.515 "Non-Criminalized" 4.215 "Criminalized") xscale(range(0 5.7))   
 text(0.96 1.4 "{it:p = 0.108}", orientation(horizontal)) 
 text(0.89 1.4 "{subscript:|}{superscript:__________________________}{subscript:|}", 
 orientation(horizontal)) text(1.12 4.2 "{it:p = 0.119}", orientation(horizontal)) 
 text(1.05 4.2 "{subscript:|}{superscript:__________________________}{subscript:|}", 
 orientation(horizontal)) text(1.3 2.9 "{it:p = 0.194}", orientation(horizontal)) 
 text(1.23 2.9 "{subscript:|}{superscript:____________________________________________________________}{subscript:|}", 
 orientation(horizontal))
 title("Health Exams"))
 barcolor(gs12) baropts(color(gs7) fintensity(inten70));


 graph export "$dout/Fig_I-II_health_exams.pdf", replace;


*EASY TO OBTAIN A CONDOM;
 *T-test for equality of means: Baseline vs Endline;

 *Non-criminalized:;
 reg condeasy  el if dataset==1 & sw==1 & full==1 & closing==0, r;
 *Criminalized:
 reg condeasy el if dataset==1 & sw==1 & full==1 & closing==1, r; 

 *Figure:;
 reg condeasy dd_cl el closing if sw==1 & dataset==1 & full==1, cluster(wsid);
 boottest  dd_cl, reps (10000) bootcluster(wsid);

 cibar condeasy if dataset==1 & sw==1 & full==1, over1(el) over2(closing) ciopts(lcolor(black))bargap(3) 
 graphopts(legend(order(1 "Baseline" 2 "Endline")) ylabel(0 "0" .1 ".1" .2 ".2" .3 ".3" .4 ".4" .5 ".5" .6 ".6" .7 ".7" .8 ".8" .9 ".9" 1 "1", angle(0)) 
 ymlabel(1.1 " " 1.2 " " 1.3 " ", nolabels tlength(zero)) ytitle("") 
 xlabel(1.515 "Non-Criminalized" 4.215 "Criminalized") xscale(range(0 5.7))   
 text(0.90 1.4 "{it:p = 0.510}", orientation(horizontal)) 
 text(0.83 1.4 "{subscript:|}{superscript:__________________________}{subscript:|}", 
 orientation(horizontal)) text(.95 4.2 "{it:p = 0.000}", orientation(horizontal)) 
 text(0.88 4.2 "{subscript:|}{superscript:__________________________}{subscript:|}", 
 orientation(horizontal)) text(1.2 2.9 "{it:p = 0.397}", orientation(horizontal)) 
 text(1.13 2.9 "{subscript:|}{superscript:____________________________________________________________}{subscript:|}", 
 orientation(horizontal))  
 title("Easy to obtain a Condom"))
 barcolor(gs12) baropts(color(gs7) fintensity(inten70));


 graph export "$dout/Fig_I-II_easy_condom.pdf", replace;


*HAS A CONDOM;
 *T-test for equality of means: Baseline vs Endline;
 *Non-criminalized:;
 reg havecondom el if dataset==1 & sw==1 & full==1 & closing==0, r;
 *Criminalized:;
 reg havecondom el if dataset==1 & sw==1 & full==1 & closing==1, r;


 *DD p-value;
 reg havecondom dd_cl el closing if sw==1 & dataset==1 & full==1, cluster(wsid);
 boottest  dd_cl, reps (10000) bootcluster(wsid);


 *Figure:;
 cibar havecondom if dataset==1 & sw==1 & full==1 , over1(el) over2(closing) ciopts(lcolor(black))bargap(3) 
 graphopts(legend(order(1 "Baseline" 2 "Endline")) ylabel(0 "0" .1 ".1" .2 ".2" .3 ".3" .4 ".4" .5 ".5" .6 ".6" .7 ".7" .8 ".8" .9 ".9" 1 "1", angle(0)) 
 ymlabel(1.1 " " 1.2 " ", nolabels tlength(zero)) ytitle("") 
 xlabel(1.515 "Non-Criminalized" 4.215 "Criminalized") xscale(range(0 5.7))   text(0.64 1.4 "{it:p = 0.000}", 
 orientation(horizontal)) text(0.58 1.4 "{subscript:|}{superscript:__________________________}{subscript:|}", 
 orientation(horizontal)) text(1.03 4.2 "{it:p = 0.000}", orientation(horizontal)) 
 text(0.97 4.2 "{subscript:|}{superscript:__________________________}{subscript:|}", orientation(horizontal)) 
 text(1.2 2.9 "{it:p = 0.002}", orientation(horizontal)) 
 text(1.13 2.9 "{subscript:|}{superscript:____________________________________________________________}{subscript:|}", 
 orientation(horizontal)) 
 title("Has a Condom"))
 barcolor(gs12) baropts(color(gs7) fintensity(inten70));

 graph export "$dout/Fig_I-II_has_condom.pdf", replace;





*EASY TO ASK CLIENT TO USE A CONDOM;
 *T-test for equality of means: Baseline vs Endline;
 *Non-criminalized:;
 reg easyask el if dataset==1 & sw==1 & full==1 & closing==0, r;
 *Criminalized:;
 reg easyask el if dataset==1 & sw==1 & full==1 & closing==1, r;

 *DD p-value:;
 reg easyask dd_cl el closing if sw==1 & dataset==1 & full==1, cluster(wsid);
 boottest  dd_cl, reps (10000) bootcluster(wsid);


 *Figure:;
 cibar easyask if dataset==1 & sw==1 & full==1, over1(el) over2(closing) ciopts(lcolor(black))bargap(3)
 graphopts(legend(order(1 "Baseline" 2 "Endline")) ylabel(0 (0.1) 1, angle(0)) 
 ytitle("") xlabel(1.515 "Non-Criminalized" 4.215 "Criminalized") xscale(range(0 5.7))   
 text(0.85 1.4 "{it:p = 0.053}", orientation(horizontal)) 
 text(0.78 1.4 "{subscript:|}{superscript:__________________________}{subscript:|}", 
 orientation(horizontal)) text(.78 4.2 "{it:p = 0.274}", orientation(horizontal)) 
 text(0.71 4.2 "{subscript:|}{superscript:__________________________}{subscript:|}", 
 orientation(horizontal)) text(1 2.9 "{it:p = 0.040}", orientation(horizontal)) 
 text(0.93 2.9 "{subscript:|}{superscript:____________________________________________________________}{subscript:|}", 
 orientation(horizontal)) 
 title("Easy to Ask Client to use a Condom"))
 barcolor(gs12) baropts(color(gs7) fintensity(inten70));


 graph export "$dout/Fig_I-II_easy_ask_condom.pdf", replace;



*CONDOM PRICE;
 *Non-criminalized:;
 reg cndmpr el if dataset==1 & sw==1 & full==1 & closing==0, r;
 *Criminalized:;
 reg cndmpr el if dataset==1 & sw==1 & full==1 & closing==1, r;

 *DD p-value:;
 reg cndmpr dd_cl el closing if sw==1 & dataset==1 & full==1, cluster(wsid);
 boottest  dd_cl, reps (10000) bootcluster(wsid);

 *Figure:;
 cibar cndmpr if dataset==1 & sw==1 & full==1, over1(el) over2(closing) ciopts(lcolor(black))bargap(3) 
 graphopts(legend(order(1 "Baseline" 2 "Endline")) ylabel(0 (200) 2000, angle(0)) ytitle("") 
 xlabel(1.515 "Non-Criminalized" 4.215 "Criminalized") xscale(range(0 5.7))   
 text(1210 1.4 "{it:p = 0.518}", orientation(horizontal)) 
 text(1125 1.4 "{subscript:|}{superscript:__________________________}{subscript:|}", 
 orientation(horizontal)) text(1690 4.2 "{it:p = 0.000}", orientation(horizontal)) 
 text(1600 4.2 "{subscript:|}{superscript:__________________________}{subscript:|}", 
 orientation(horizontal)) text(1940 2.9 "{it:p = 0.080}", orientation(horizontal)) 
 text(1850 2.9 "{subscript:|}{superscript:____________________________________________________________}{subscript:|}", 
 orientation(horizontal))  
 title("Condom Price"))
 barcolor(gs12) baropts(color(gs7) fintensity(inten70));


 graph export "$dout/Fig_I-II_condom_price.pdf", replace;




*NO CONDOM USED - FSWs;
 *Non-criminalized:;
 reg noco1 el if dataset==2 &full==1 & closing==0, r;
 *Criminalized:;
 reg noco1 el if dataset==2 &full==1 & closing==1, r;


 *DD p-value:;
 areg noco1 dd_cl el closing if dataset==2 & full==1, cluster(wsid) abs(fsw_fe);
 boottest  dd_cl, reps (10000) bootcluster(wsid);


 *Figure:;
 cibar noco1 if dataset==2 &full==1, over1(el) over2(closing) ciopts(lcolor(black))bargap(3) 
 graphopts(legend(order(1 "Baseline" 2 "Endline")) ylabel(0 (.1) 1, angle(0)) ytitle("") 
 xlabel(1.515 "Non-Criminalized" 4.215 "Criminalized") xscale(range(0 5.7))   
 text(0.45 1.4 "{it:p = 0.162}", orientation(horizontal)) 
 text(0.4 1.4 "{subscript:|}{superscript:__________________________}{subscript:|}", 
 orientation(horizontal)) text(0.32 4.2 "{it:p = 0.738}", orientation(horizontal)) 
 text(0.28 4.2 "{subscript:|}{superscript:__________________________}{subscript:|}", 
 orientation(horizontal)) text(0.8 2.9 "{it:p = 0.334}", orientation(horizontal)) 
 text(0.73 2.9 "{subscript:|}{superscript:____________________________________________________________}{subscript:|}", 
 orientation(horizontal))
 title("No Condom Used - Sex Worker Reports"))
 barcolor(gs12) baropts(color(gs7) fintensity(inten70));


 graph export "$dout/Fig_I-II_no_condom_women.pdf", replace;


*NO CONDOM USED - Client Reports;
 *Non-criminalized:;
 reg noco1 el if dataset==4 & closing==0, r;
 *Criminalized:;
 reg noco1 el if dataset==4 & closing==1, r;

 *DD p-value:;
 areg noco1 	dd_cl el closing if dataset==4, cluster(ws_wave) abs(cl_fe);
 boottest  dd_cl, reps (100000) bootcluster(ws_wave);

 *Figure:;
 cibar noco1 if dataset==4, over1(el) over2(closing) ciopts(lcolor(black))bargap(3) 
 graphopts(legend(order(1 "Baseline" 2 "Endline")) ylabel(0 (.1) 1, angle(0)) 
 ytitle("") xlabel(1.515 "Non-Criminalized" 4.215 "Criminalized") xscale(range(0 5.7))   
 text(0.7 1.4 "{it:p = 0.388}", orientation(horizontal)) 
 text(0.65 1.4 "{subscript:|}{superscript:__________________________}{subscript:|}", 
 orientation(horizontal)) text(0.65 4.2 "{it:p = 0.000}", orientation(horizontal)) 
 text(0.6 4.2 "{subscript:|}{superscript:__________________________}{subscript:|}", 
 orientation(horizontal)) text(0.9 2.9 "{it:p = 0.044}", orientation(horizontal)) 
 text(0.83 2.9 "{subscript:|}{superscript:____________________________________________________________}{subscript:|}", 
 orientation(horizontal)) 
 title("No Condom Used - Client Reports"))
 barcolor(gs12) baropts(color(gs7) fintensity(inten70));


 graph export "$dout/Fig_I-II_no_condom_clients.pdf", replace;


***************************************************;

*CONDOM INDEX:;
 *T-test for equality of means: Baseline vs Endline;
 *Non-criminalized:
 reg cndom_index el if dataset==1 & sw==1 & full==1  & closing==0, r;
 *Criminalized:;
 reg cndom_index el if dataset==1 & sw==1 & full==1  & closing==1, r;


 *For the DD p-value:;
 reg cndom_index dd_cl el closing `sw1', cluster(wsid);
 boottest  dd_cl, reps (100000) bootcluster(wsid);


 *Figure:;
 cibar cndom_index if dataset==1 & sw==1 &full==1, over1(el) over2(closing) 
 ciopts(lcolor(black))bargap(3) graphopts(legend(order(1 "Baseline" 2 "Endline")) 
 ylabel(0 (0.1) -1.4, angle(0)) ytitle("") 
 ylabel(0 "0" -.1 "-.1" -.2 "-.2" -.3 "-.3" -.4 "-.4" -.5 "-.5" -.6 "-.6" -.7 "-.7" -.8 "-.8" -.9 "-.9" -1 "-1", angle(0)) 
 ymlabel(-1.1 " " -1.2 " " -1.3 "-1.3" -1.4 "-1.4", nolabels tlength(zero)) ytitle("") 
 xlabel(1.515 "Non-Criminalized" 4.215 "Criminalized") 
 xscale(range(0 5.7))   text(-0.50 1.4 "{it:p = 0.613}", orientation(horizontal)) 
 text(-0.49 1.4 "{superscript:|}{superscript:__________________________}{superscript:|}", 
 orientation(horizontal)) text(-1.10 4.2 "{it:p = 0.000}", orientation(horizontal)) 
 text(-1.09 4.2 "{superscript:|}{superscript:__________________________}{superscript:|}", 
 orientation(horizontal)) text(-1.30 2.9 "{it:p = 0.007}", orientation(horizontal)) 
 text(-1.29 2.9 "{superscript:|}{superscript:____________________________________________________________}{superscript:|}", 
 orientation(horizontal)) 
 yline(0, lcolor(gs14)) title("Condom Use Index"))
 barcolor(gs12) baropts(color(gs7) fintensity(inten70));


 graph export "$dout/Fig_I-II_condom_index.pdf", replace;

